<!DOCTYPE HTML>
<html>
<head>
  <title>秒杀活动</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <!-- jquery -->
  <script type="text/javascript" src="/js/jquery.min.js"></script>
  <!-- bootstrap -->
  <link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.min.css"/>
  <script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
  <!-- jquery-validator -->
  <script type="text/javascript" src="/jquery-validation/jquery.validate.min.js"></script>
  <script type="text/javascript" src="/jquery-validation/localization/messages_zh.min.js"></script>
  <!-- layer -->
  <script type="text/javascript" src="/layer/layer.js"></script>
  <!-- md5.js -->
  <script type="text/javascript" src="/js/md5.min.js"></script>
  <!-- common.js -->
  <script type="text/javascript" src="/js/common.js"></script>
</head>
<style>
  .seckill-banner {
    width: 100vw;
    height: 90px;
  }
  .seckill-banner img {
    width: 100%;
    height: 100%;
  }
</style>
<body>
<div class="seckill-banner">
  <img src="/img/seckill-logo.jpg"/>
</div>
<div class="panel panel-default" id='goods_panel'>
  <div class="panel-heading">秒杀活动列表</div>
  <div id="goods_list">
  </div>
</div>
</body>
<script type="text/javascript">
  const accessToken = localStorage.getItem("accessToken");
  let strs = [];
  function renderActivityList(list) {

    list.forEach(activity => {
    let str = `
    <li>
      <table class="table" id="goodslist">
        <tr>
          <td>活动名称</td>
          <td>秒杀价</td>
          <td>库存数量</td>
          <td>详情</td>
        </tr>
        <tr>
          <td>秒杀活动${activity.promoId}</td>
          <td>${activity.price}</td>
          <td>${activity.num}</td>
          <td><a href="/goods_detail.html/?skuId=${activity.skuId}&promoId=${activity.promoId}&accessToken=${accessToken}">详情</a></td>
        </tr>
      </table>
    </li>
    `;
    strs.push(str);
  });
  document.getElementById("goods_list").innerHTML = `<ul>${strs.join('')}</ul>`;
  }
  $.ajax({
      url: "/promos",
      type: "GET",
      dataType: 'json',
      data: {
        accessToken,
      },
      success: renderActivityList,
      error: function (res) {
        console.log(res);
      }
    });
</script>
</html>
